package com.shengzai.hbase;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.Admin;
import org.apache.hadoop.hbase.client.Connection;
import org.apache.hadoop.hbase.client.ConnectionFactory;

import java.io.IOException;

public class TableExists {
    public static void main(String[] args) throws IOException {
        Configuration conf = new Configuration();
        conf.set("hbase.zookeeper.quorum","master,node1,node2");
        Connection connection = ConnectionFactory.createConnection(conf);
        Admin admin = connection.getAdmin();
        TableName tableName = TableName.valueOf("api_test:api_student");
        boolean apiStudent = admin.tableExists(tableName);
        if (apiStudent){
            System.out.println(tableName.getNameAsString()+"存在");
        }else
            System.out.println(tableName.getNameAsString()+"不存在");
        admin.close();
        connection.close();
    }


}
